***** 
*** Reassessing Public Support for a Female President
*** Stata code for Appendix replication Table A2
*** Prepared by Yoshikuni Ono
*** Date 2017/2/27
*****

** Table A2 Opposition to a Female President with Weights

* Change file pathname is needed
use "PATHNAME/JoP_Stata_data.dta"

gen weight = wgt * 1578

gen all_c = q27_c * weight if q27_c > -1
gen all_t = q27_t * weight if q27_t > -1

* All respondents
ttest all_c = all_t, unp

* Male respondents
ttest all_c = all_t if male == 1, unp

* Female respondents
ttest all_c = all_t if male == 0, unp

* No BA respondents
ttest all_c = all_t if edu > 0 & edu < 6, unp

* BA respondents
ttest all_c = all_t if edu >5, unp

* 18-29 years old
ttest all_c = all_t if age < 30, unp

* 30-50 years old
ttest all_c = all_t if age > 29 & age < 51, unp

* 51-65 years old
ttest all_c = all_t if age > 50 & age < 66, unp

* 66- years old
ttest all_c = all_t if age > 65, unp

* Lower and Lower middle class
ttest all_c = all_t if class > 0 & class < 3, unp

* Middle class
ttest all_c = all_t if class == 3, unp

* Upper and upper middle class
ttest all_c = all_t if class > 3, unp

* South
ttest all_c = all_t if south == 1, unp

* Nonsouth
ttest all_c = all_t if south == 0, unp

* White
ttest all_c = all_t if white == 1, unp

* Hispanic
ttest all_c = all_t if hispanic == 1, unp

* Black
ttest all_c = all_t if black == 1, unp

* Others
ttest all_c = all_t if white == 0 & hispanic == 0 & black == 0, unp

* Democrats
ttest all_c = all_t if party == 2, unp

* Republicans
ttest all_c = all_t if party == 1, unp

* Independents
ttest all_c = all_t if party == 3, unp
